home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
COMM
/
INTERNET
/
TELNET
/
RLOGIND
/
!RloginD
/
telnet
/
term_h
< prev
Wrap
Text File
|
1993-09-02
|
4KB
|
162 lines
/* > term.h
* (C) 1992 Andrew Brooks
* arb@comp.lancs.ac.uk
* 1.00 Fri Feb 5 11:51:16 GMT 1993
* First incarnation
*/
/*
* System-independent terminal handling library.
* When compiling this library the appropriate flags must be set:
* TERMIO
* This is typically on System III and System V (and SunOS)
* Look for a termio.h header file and termio manual page
* #define TERMIO
* SGTTY
* This is typically on Version 7 systems
* Look for a sgtty.h header file
* #define SGTTY
* ITTY
* This is typically on BSD systems
* Look for a ioctl.h header file and a tty(4) manual page
* #define ITTY
* If more than one of the above applies (eg.SunOS) then use TERMIO
* If none of the above apply then you are stuck.
*/
#ifndef __term_h
#define __term_h
#include "cproto.h"
/* Simple error check */
#ifndef TERMIO
#ifndef SGTTY
#ifndef ITTY
/* Have a good try at guessing */
/* Try Sequent DynixPTX */
#ifdef _SEQUENT_
#define TERMIO
#endif /* _SEQUENT_ */
/* Try Sequent Dynix */
#ifdef sequent
#define ITTY
#endif /* sequent */
/* Try Sun (assume SunOS 4) */
#ifdef sun
#define TERMIO
/* Sun can use both termio and termios. Prefer termio for compatibility */
#endif /* sun */
#endif
#endif
#endif
/* See if all those failed */
#ifndef TERMIO
#ifndef SGTTY
#ifndef ITTY
error One of TERMIO, SGTTY or ITTY must be defined (see term.h)
#endif
#endif
#endif
/* First include the correct header file */
#ifdef TERMIO
/* On some termio systems this would be <sys/termio.h> */
/* SunOS would be one example but luckily it has symbolic links so no need */
#include <termio.h>
#endif
#ifdef SGTTY
#include <sgtty.h>
#endif
#ifdef ITTY
/* This may be <ioctl.h> or <sys/ioctl.h> ? */
#include <sys/ioctl.h>
/* All this junk is needed because these system are a big hack */
struct itty
{
struct sgttyb sgttyb;
struct tchars tchars;
struct ltchars ltchars;
long lmode;
};
#endif
#include <fcntl.h> /* for open(2) modes */
#define TERM_MIN 4 /* minimum characters to satisfy read() */
#define TERM_TIME 5 /* intercharacter delay for read() */
#define BUFSIZE 1024 /* used for Term_CopyStuff */
/* Common structures and ioctls */
#ifdef TERMIO
#define TERM_STRUCT struct termio
#define TERM_GET TCGETA
#define TERM_SET TCSETA
/* TCSETAW may be used to wait for all pending output characters to be sent
* first, useful when altering output modes. TCSETAF may be used to flush
* the input queue first, useful when typeahead may not be desirable.
*/
/* Be careful, SETS is for termios, SETA is for termio */
#endif
#ifdef SGTTY
#define TERM_STRUCT struct sgttyb
#define TERM_GET TIOCGETP
#define TERM_SET TIOCSETP
#endif
#ifdef ITTY
#define TERM_STRUCT struct itty
#define TERM_GET TIOCGETP /* not used */
#define TERM_SET TIOCSETP /* not used */
#endif
/* On some systems O_NDELAY and FNDELAY are equivalent */
#ifdef SGTTY
#define TERM_SETNONBLOCKING O_NDELAY
#define TERM_WOULDBLOCK EAGAIN
#endif
#ifdef TERMIO
#define TERM_SETNONBLOCKING O_NDELAY
#define TERM_WOULDBLOCK EAGAIN
#endif
#ifdef ITTY
#define TERM_SETNONBLOCKING FNDELAY
#define TERM_WOULDBLOCK EWOULDBLOCK
#endif
/* Now declare the public term_ functions */
/*
* Save and restore the full status of the terminal associated with the
* file descriptor. Includes such items as raw, echo, mappings etc.
* Declare a TERM_STRUCT and pass a pointer to it for filling in.
*/
extern int Term_Save P_((int fd, TERM_STRUCT *bug));
extern int Term_Restore P_((int fd, TERM_STRUCT *buf));
/*
* Set the file descriptor to be raw (not cooked) I/O.
* Note that restoring NonRaw puts the fd back in full non-raw mode,
* cbreak is never used.
*/
extern int Term_Raw P_((int fd));
extern int Term_NonRaw P_((int fd));
/*
* Turn off echoing only
*/
extern int Term_NoEcho P_((int fd));
#endif /* __term_h */